/**
 * 
 */
package com.caonima.proxy;

import com.caonima.dao.IAdminDao;
import com.caonima.dao.impl.AdminDaoImpl;
import com.caonima.dbc.DatabaseConnection;
import com.caonima.vo.Admin;

/**
 * @author Administrator
 *
 */
public class AdminDaoProxy implements IAdminDao {
	private DatabaseConnection dbc = null;
	private IAdminDao dao = null;
	public AdminDaoProxy(){
		try{
			this.dbc = new DatabaseConnection();
		}catch(Exception e){
			e.printStackTrace();
		}
		this.dao = new AdminDaoImpl(this.dbc.getConnection());
	}
	@Override
	public boolean doCreate(Admin admin) throws Exception {
		boolean flag = false;
		try{
			flag = this.dao.doCreate(admin);
		} catch (Exception e) {
			throw e;
		} finally{
			this.dbc.close();
		}
		return flag;
	}
	@Override
	public Admin findById(String aid) throws Exception {
		Admin admin = null;
		try {
			admin = this.dao.findById(aid);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return admin;
	}
	@Override
	public boolean doUpdatePwd(Admin admin) throws Exception {
		boolean flag = false;
		try {
			flag = this.dao.doUpdatePwd(admin);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return flag;
	}

}
